const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    cur: 0,
    tab: [],
    theme: app.theme,
    windowWidth:app.globalData.windowWidth,
  },
  attached() {
    this.setData({
      tab:app.data.tab
    })
  },
  /**
 * 组件的方法列表
   */
  methods: {

    tocurrent(e) {
      console.info(this);
      let item = e.currentTarget.dataset.item;
      let index = e.currentTarget.dataset.index;
      //每个tab选项宽度占1/3
      var singleNavWidth = this.data.windowWidth / 3;

      this.setData({
        cur: index,
        navScrollLeft: (index - 2) * singleNavWidth
      }, () => {
        let pages = getCurrentPages(); //获取加载的页面
        let currentPage = pages[pages.length - 1]; //获取当前页面的对象
        let url = currentPage.route;//当前页面url
        // app.cache[url].getSwitchProducts(index, item);
      })


    }
  }
})
